package com.dz.Incubator.service.impl;

import com.dz.Incubator.dao.SysRoleDao;
import com.dz.Incubator.entity.SysRoleEntity;
import com.dz.Incubator.service.SysRoleService;
import com.dz.Incubator.config.Pagination;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SysRoleServiceImpl implements SysRoleService {

	private static final Logger logger = LoggerFactory.getLogger(SysRoleService.class);

    @Autowired
    private SysRoleDao sysRoleDao;

    @Override
    public SysRoleEntity insert(SysRoleEntity sysRoleEntity) {
        sysRoleDao.insert(sysRoleEntity);
        
        return sysRoleEntity;
    }

    @Override
    public SysRoleEntity update(SysRoleEntity sysRoleEntity) {
        sysRoleDao.update(sysRoleEntity);
        
        return sysRoleEntity;
    }

    @Override
    public Integer delete(Long id) {
        int ret = sysRoleDao.delete(id);
        return ret;
    }
    
    @Override
    public List<SysRoleEntity> find(Long[] ids) {
        List<SysRoleEntity> datas = sysRoleDao.find(ids);
        return datas;
    }

    @Override
    public SysRoleEntity get(Long id) {
        SysRoleEntity sysRoleEntity = sysRoleDao.get(id);
        return sysRoleEntity;
    }

    @Override
    public List<SysRoleEntity> findAll() {
    	List<SysRoleEntity> datas = sysRoleDao.findAll();
    	return datas;
    }
    
    @Override
    public Pagination findByPagination(Pagination pagination) {
    	List<SysRoleEntity> datas = sysRoleDao.findByPagination(pagination);
    	pagination.setList(datas);
    	return pagination;
    }
	
	@Override
    public List<SysRoleEntity> insertBatch(List<SysRoleEntity> list) {
        int ret = sysRoleDao.insertBatch(list);
        return list;
    }
    
    @Override
    public List<SysRoleEntity> updateBatch(List<SysRoleEntity> list) {
        int ret = sysRoleDao.updateBatch(list);
        return list;
    }
    
    @Override
    public List<Long> deleteBatch(Long[] ids) {
        int ret = sysRoleDao.deleteBatch(ids);
        List<SysRoleEntity>  datas = sysRoleDao.find(ids);
        List<Long> list = new ArrayList<Long>();
        for (SysRoleEntity data : datas) {
        	list.add(data.getId());
        }
        return list;
    }
}